Repository navigation
fix: named errors for missing stages/unresolved aliases; ruby gains the four ISC fn literals (WO18 G3/G4/G8) - #849
Merged
Merged
Conversation
…ns the four ISC fn literals WO18 G3/G4/G8 from the merged four-runtime parity audit (maps docs/parity/README.md, PR #275). G4 - missing stage (ruby + py): ruby raised an accidental NoMethodError (nil stage flowing into execute_rule) for both a requested missing main stage and a missing run target; Interpreter#call and the Run arm now raise Interscript::MapLogicError with the rs message shape (stage "<name>" not found in <map name>). py's execute_stage silently returned the input on a missing stage; it now raises MapLogicError with the same shape. Run-target stages already raise in py. G3 - unresolved alias (py): interscript-py compiled an unresolved alias to the empty matcher (re ""), matching at every string boundary and silently splicing the replacement text ("a" -> "XaX"); items.py now raises MapLogicError "Alias <name> not found", mirroring ruby's SystemConversionError and rs's load-time error. (The ts side ships separately.) G8 - fn literals (ruby): The ISC grammar surface includes the upcase/reverse/strip/swapcase fn literals, but Stdlib::Functions implemented none of them, so the upcase stage directive crashed with NoMethodError. Add all four to Stdlib::Functions and Stdlib.available_functions; upcase mirrors the ts/py/rs directive semantics (String#upcase = to_uppercase). reverse/strip/swapcase use plain String semantics: no other runtime executes them yet (verified - ts/py skip the rule, rs rejects at load), so there was no cross-runtime reference to mirror. The legacy DSL keeps upcase as the to-symbol builder (sub "a", upcase; pinned by dsl_stage_spec and Interpreter's to == :upcase special-case), so the available_functions loop skips it there. Behavior note for py consumers (G4): requesting a missing stage now raises instead of returning the input unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WO18 G3/G4/G8 from the merged four-runtime parity audit (maps
docs/parity/README.md, PR #275) — the ruby engine and interscript-pyin one PR; the ts side ships separately.
with an accidental
NoMethodError(nil flowed intoexecute_rule),and a missing run target crashed with
NoMethodError undefined method 'reverse_run' for nil.Interpreter#calland theRunarmnow raise
Interscript::MapLogicErrorwith rs's message shape:stage "nope" not found in <map name>.execute_stagesilently returned theinput on a missing stage (docstring said "matching the TS runtime").
Now raises
MapLogicErrorwith the same shape.API-visible change for consumers who relied on the no-op.
to the EMPTY matcher (
re: ""— matches at every string boundary),silently splicing the replacement text:
sub unknown_alias "X",input
"a"gave"XaX".items.pynow raisesMapLogicError "Alias <name> not found"(ruby's message; ruby itself unchanged —already raises
SystemConversionError).upcase/reverse/strip/swapcasefn literals, butStdlib::Functionsimplemented none — theupcasestage directivecrashed with
NoMethodError undefined method 'upcase' for module Interscript::Stdlib::Functions(audit probefuncall-upcase-exec).All four added to
Stdlib::FunctionsandStdlib.available_functions.upcasemirrors the ts/py/rsdirective semantics (
String#upcase=to_uppercase).reverse/strip/swapcaseuse plain String semantics: verifiedthat no other runtime executes them yet (ts/py skip the rule, rs
rejects at load), so there is no cross-runtime reference to mirror.
The legacy DSL keeps
upcaseas the to-symbol builder(
sub "a", upcase, pinned by dsl_stage_spec and the Interpreter'sto == :upcasespecial-case) — theavailable_functionsloopskips it there.
Test plan
(
spec/isc/fail_loud_spec.rb4 red;spec/stdlib_functions_spec.rb5 red; py
test_missing_stage_raises+test_unresolved_alias_raisesboth "DID NOT RAISE") -> green after the fix.
to a clean origin/main worktree run (106 pre-existing env failures
on this machine — PyCall pointing at a stale wf1-hebraic tree —
unchanged by this diff; +9 new examples, all passing).
main (
test_api.py::test_transliterate_known_vector, un-bulembedded vector), untouched by this diff.
maps scripts/parse-parity.mjs): output byte-identical to the origin/mainbaseline run (412/435, same divergence counts) — no grammar files
touched.
scripts/parse_parity_py.py --hand-rev 80bee0a~1: canonical 435/435, raw 435/435.tst-upcase-exec->" ABC"(was NoMethodError); missing stage/run-target -> named
MapLogicError (was NoMethodError); py/ts probes -> same named
errors.